package com.itjava.mt.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.itjava.mt.cmn.mapper.DictMapper;
import com.itjava.mt.model.cmn.Dict;
import com.itjava.mt.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;

/**
 * 开发工具：IntelliJ IDEA
 * 项目名称：medical_treatment
 * 包路径：  com.itjava.mt.cmn.listener
 * 创作时间： 2021/6/4 21:58
 */
public class DictListener extends AnalysisEventListener<DictEeVo> {

        private DictMapper dictMapper;
        public DictListener(DictMapper dictMapper) {
            this.dictMapper = dictMapper;
        }

        //一行一行读取
        @Override
        public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
            //调用方法添加数据库
            Dict dict = new Dict();
            BeanUtils.copyProperties(dictEeVo,dict);
            dictMapper.insert(dict);
        }
        @Override
        public void doAfterAllAnalysed(AnalysisContext analysisContext) {

        }
}
